package com.lx.screenshot.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SPUtil {
    public static final String SP_KEY = "sharePre_key";

    public static void put(Context context, String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE);
        sharedPreferences.edit()
                .putString(key, value)
                .apply();
    }
    public static void put(Context context, String key, Boolean value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE);
        sharedPreferences.edit()
                .putBoolean(key, value)
                .apply();
    }

    public static String get(Context context, String key, String defVal) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, defVal);
    }
    public static Boolean get(Context context, String key, Boolean defVal) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(SP_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getBoolean(key, defVal);
    }
}
